/*
 * Path
 * 
 * initial implementation : 28.8.2007
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
//using System.Collections.Generic;
//using System.Text;
//using Petra.Gis.Geometry.Support;


namespace Petra.Gis.Geometry
{
  /// <summary>
  /// Path geometry represents composite curve
  /// input geometry types is limited to Arc and LineString
  /// each previous geometry must extend next one from same point
  /// previous.endPoint = next.startPoint
  /// </summary>
  public class Path : GeometryCollection
  {


    public Path()
    {
      System.Type[] _tl = {
                           typeof(Arc),
                           typeof(LineString)
                          };
      typeLimits = _tl;
    }





    public override void Add(GeometryBase oGeom)
    {
      Curve tmpGeom;
      tmpGeom = (Curve)oGeom;
      //validate if input component startPoint == endPoint, invalid geometry input !!
      if (tmpGeom.coordList.startPoint.Equals(tmpGeom.coordList.endPoint, tmpGeom.coordList.dimension))
        throw new ArgumentException("can't add geometry which startPoint = endPoint (enclosed)");

      if (this.Count == 0)
        base.Add(oGeom);
      else
      {
        //when using add, valiate if last point of prev is same as first of current !!
        tmpGeom = (Curve)this[this.Count - 1];
        if (tmpGeom.coordList.endPoint.Equals(((Curve)oGeom).coordList.startPoint, tmpGeom.coordList.dimension))
          throw new ArgumentException("can't add geometry which startPoint don't match polylineGeometry last component endPoint");
        else
          base.Add(oGeom);
      }
    }


  }
}
